package com.elcl.util;

import android.content.res.Resources;
import android.graphics.drawable.Drawable;

import com.elcl.storage.ApplicationCache;

/**
 * @author LCL 2014-11-24
 */
public class ResourceUtils {
	private static Resources resources = null;

	public static Resources getResources() {
		if (null == resources) {
			resources = ApplicationCache.context.getResources();
		}
		return resources;
	}

	/**
	 * 2014-11-24 LCL
	 * 
	 * @param StringId
	 * @return 获取String文件中的id
	 */
	public static String getString(int StringId) {
		String result = "";
		String content = getResources().getString(StringId);
		if (StringUtils.isEmpty(result)) {
			result = content;
		}
		return result;
	}

	/**
	 * 2014-11-24 LCL
	 * 
	 * @return 获取Dimen文件中的id
	 */
	public static int getDimen(int dimenId) {
		return (int) getResources().getDimension(dimenId);
	}

	public static int getColor(int colorId) {
		return getResources().getColor(colorId);
	}

	public static Drawable getDrawable(int drawableId) {
		return getResources().getDrawable(drawableId);
	}

}
